<template>
  <div style="padding-bottom:2px;" >
     <v-UploadOpen v-if="this.ToolBarList.filter(item => item.ButtonCode =='import').length>0" 
                    @returnData="handeimport"
                    :UploadArr = 'UploadArr'
                  ></v-UploadOpen>
        <el-button type="primary" icon="el-icon-search" size="mini" v-on:keydown.enter="handegetDataList()" @click="handegetDataList()">查询</el-button>
        <el-button v-if="this.ToolBarList.filter(item => item.ButtonCode =='export').length>0" type="warning" icon="el-icon-download" @click="handlexportData()" size="mini"  >导出</el-button>
        <!-- <el-button v-if="this.ToolBarList.filter(item => item.ButtonCode =='import').length>0" type="success" icon="el-icon-download" size="mini"   @click="handeimport()">导入</el-button> -->
         
  
        <el-button v-if="this.ToolBarList.filter(item => item.ButtonCode =='add').length>0" type="success" icon="el-icon-circle-plus-outline" @click="handeAdd()" size="mini"  >新增</el-button>  
        <el-button v-if="this.ToolBarList.filter(item => item.ButtonCode =='save').length>0" type="success" icon="el-icon-circle-plus-outline" @click="handesave()" size="mini"  >保存</el-button> 
        <el-button v-if="this.ToolBarList.filter(item => item.ButtonCode =='delete').length>0&&this.Isdelete==true" type="danger" icon="el-icon-circle-plus-outline" @click="handedelete()" size="mini"  >删除</el-button> 
        <el-button v-if="this.ToolBarList.filter(item => item.ButtonCode =='print').length>0" type="warning" icon="el-icon-circle-plus-outline" v-print="'#PrintDate-id'" size="mini"  >打印</el-button>     
        <el-button v-if="this.ToolBarList.filter(item => item.ButtonCode =='count').length>0" type="warning" icon="el-icon-circle-plus-outline" @click="handlecount()" size="mini"  >运算</el-button>
        <el-button v-if="this.ToolBarList.filter(item => item.ButtonCode =='close').length>0" type="warning" icon="el-icon-circle-plus-outline" @click="handleclose()" size="mini"  >关单</el-button>
        <el-button v-if="this.ToolBarList.filter(item => item.ButtonCode =='submit').length>0" type="warning" icon="el-icon-circle-plus-outline" @click="handleALLsubmit()" size="mini"  >批量提交</el-button>
        <el-button v-if="this.ToolBarList.filter(item => item.ButtonCode =='order').length>0" type="warning" icon="el-icon-circle-plus-outline" @click="handleOrder()" size="mini"  >接单</el-button>
        <!-- <el-button type="success" v-print="'#printMain'" size="mini">打印</el-button> -->
  </div>

</template>

<script>
  import path from 'path'
  import { deepClone } from '@/utils'
  import { GetToolBarList} from '@/api/GetToolBar'
import vUploadOpen from "../Common/UploadOpen";
  // 默认的编辑字段
  const defaultObject = {};
   export default {
    name: "DataList",
    props: {
    MenuCode: String,
    required: true,
    UploadArr: [],
    Isdelete:false
  },   components:{ //引入组件后注册组件
       vUploadOpen
   },
    data() {
      return {  ToolBarList:[],
      }
    },
    computed: {
      routesData() {
        return this.routes
      }
    },
       created() {
     
 
      this.getLoadingList()
//控制行编辑
     


    },

    methods: {

       handeAdd() {

      this.$emit('handeAdd');
      this.$parent.handeAdd()
     },
    
     handleEdit(scope) { // 修改
        this.$emit('handleEdit');
      },
     handleALLsubmit(scope) { // 修改
       this.$emit('handleALLsubmit');
      },
     handegetDataList(scope) { // 修改
      this.$emit('OpenFindForm');

      },
      handlexportData()
      {
        this.$emit('handlexportData');
      },
       handlecount()
      {
        this.$emit('handlecount');
      },
       handleclose()
      {
        this.$emit('handleclose');
      },handleOrder()
      {
        this.$emit('handleOrder');
      },handeimport(Uploadlist)
      {
        this.$emit('handeimport', Uploadlist);
      },handesave()
      {
        this.$emit('handesave');
      },handedelete()
      {
        this.$emit('handedelete');
      },
      handeprint()
      {
        this.$emit('handeprint');
      },
      
      
      async getLoadingList() { // 获取列表数据，通用

        const res = await GetToolBarList({ MenuCode:this.MenuCode })
        this.ToolBarList = res.data //将data 中的数据放到DataList中

     if(this.ToolBarList.filter(item => item.ButtonCode =='edit').length>0)
     {
        this.$emit('IsfunEdit');
        
     }

     if(this.ToolBarList.filter(item => item.ButtonCode =='delete').length>0)
     {
         this.$emit('IsfunDelete');
       
     }

      if(this.ToolBarList.filter(item => item.ButtonCode =='fail').length>0)
     {
        this.$emit('Isfunfail');
      
     }



     
        
      },

     },
      
      
    
      
    
    
  }

  </script>

<style lang="scss" scoped>
  .app-container {
    .EditObjs-table

  {
    margin-top: 3px;
  }

  .permission-tree {
    margin-bottom: 3px;
  }
  }
</style>
